package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcDemo04 {
    public static void main(String[] args) {
        try(
                Connection connection = DbUtil.getConnection();
                ) {
            Statement statement = connection.createStatement();
            String str = "SELECT id, name, salary, title\n" +
                         "FROM teacher";
            ResultSet rs = statement.executeQuery(str);
            while (rs.next()){
                int id = rs.getInt("id");
                String name = rs.getString("name");
                int salary   = rs.getInt("salary");
                String title = rs.getString("title");
                System.out.println(id+" "+name+" "+salary+" "+title+" ");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
